﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="inbox.aspx.cs" Inherits="AnyOffice.general.email.inbox" %>

<%@ Register TagPrefix="Webdiver" Namespace="Webdiver" Assembly="AspnetPager" %>
<HTML>
	<HEAD>
		<TITLE>收件箱</TITLE>
		
		<script language="JavaScript">
 function CheckAll( checkAllBox )                         
 {                                                                  
 var frm = document.Form1;                               
  var ChkState=checkAllBox.checked;                   
  for(i=0;i< frm.length;i++)                                 
  {                                                                 
         e=frm.elements[i];                                   
        if(e.type=='checkbox' && e.name.indexOf('EmailId') != -1)
            e.checked= ChkState ;                        
  }                                                               
 }                                                                
                           
function CheckChanged()                                   
{                                                                   
  var frm = document.Form1;                              
  var boolAllChecked;                                         
  boolAllChecked=true;                                       
  for(i=0;i< frm.length;i++)                                 
  {                                                                 
    e=frm.elements[i];                                        
  if ( e.type=='checkbox' && e.name.indexOf('EmailId') != -1 )
      if(e.checked== false)                                  
      {                                                             
         boolAllChecked=false;                               
         break;                                                    
      }                                                              
  }                                                                  
  for(i=0;i< frm.length;i++)                                  
  {                                                                  
    e=frm.elements[i];                                         
    if ( e.type=='checkbox' && e.name.indexOf('checkAll') != -1 )
    {                                                            
      if( boolAllChecked==false)                         
         e.checked= false ;                                
         else                                                    
         e.checked= true;                                  
      break;                                                    
    }                                                             
   }                                                              
 }    
                                                             
		</script>		
	</HEAD>
	<body class="bodycolor" topMargin="5">
		<form id="Form1" method="post" runat="server">
			<table class="small" cellSpacing="0" cellPadding="3" width="100%" border="0">
				<tr>
					<td class="Big" width="30%"><IMG height="18" src="/images/menu/inbox.gif" width="18" align="absMiddle"> <span class="big3"><asp:Literal id="litNavTitle" runat="server"></asp:Literal></span>
					</td>
					<td vAlign="bottom" width="30%">
						<asp:Literal id="litNavCount" runat="server"></asp:Literal>
					</td>
					<td vAlign="bottom" width="40%">
						<asp:Literal id="litNavPager" runat="server"></asp:Literal>
					</td>
				</tr>
			</table>			
			<asp:Panel id="pnlMain" runat="server">
			<br>
				<TABLE class="small" cellSpacing="1" cellPadding="3" width="95%" bgColor="#000000" border="0">
					<TR class="TableHeader">
						<TD noWrap align="center">选择</TD>
						<TD noWrap align="center">状态</TD>
						<TD noWrap align="center">发件人</TD>
						<TD noWrap align="center">主题 [点击前为新邮件]</TD>						
						<TD noWrap align="center">日期</TD>
						<TD noWrap align="center">大小</TD>
					</TR>
					<asp:Repeater id="rptEmail" runat="server">
						<ItemTemplate>
						<tr class="TableLine1">
						<td noWrap align="center"><input type="checkbox" runat="server" id="EmailId" onclick="CheckChanged();" name="EmailId" value='<%#Eval("EmailId")%>' /></td>
						<td noWrap align="center">
						<%#(Convert.ToBoolean(Eval("ReadFlag")) == true) ? "<img title='已读' src='/images/email_open.gif' border='0'>" : ""%>
						<%#(Convert.ToBoolean(Eval("ReadFlag")) == false) ? "<img title='未读' src='/images/email_new.gif' border='0'>" : ""%>
						</td>
						<td noWrap align="center"><u title="部门：<%#Eval("DeptName")%>" style="cursor:hand"><%#Eval("UserName")%></u></td>
						<td>
						    <a href="inbox_read_email.aspx?email_id=<%#Eval("EmailId")%>&box_id=<%#Eval("BoxId")%>&page=<%=ViewState["CurrentPage"]%>">
						    <%#Eval("Subject").ToString() == "" ? "[无主题]" : Eval("Subject").ToString()%>
						    <%#(Convert.ToInt32(Eval("Important")) == 1) ? "<span class=\"TextColor1\">重要</span>" : ""%>
						    <%#(Convert.ToInt32(Eval("Important")) == 2) ? "<span class=\"TextColor1\">非常重要</span>" : ""%>
						    </a>
						</td>
						<td noWrap align="center"><%#Eval("SendTime")%></td>
						<td noWrap align="center"><%#formatSize(Convert.ToInt64(Eval("TotalSize")))%></td>
					</tr>
					</ItemTemplate>
					<AlternatingItemTemplate>
					<tr class="TableLine2">
						<td noWrap align="center"><input type="checkbox" runat="server" id="EmailId" onclick="CheckChanged();" name="EmailId" value='<%#Eval("EmailId")%>' /></td>
						<td noWrap align="center">
						<%#(Convert.ToBoolean(Eval("ReadFlag")) == true) ? "<img title='已读' src='/images/email_open.gif' border='0'>" : ""%>
						<%#(Convert.ToBoolean(Eval("ReadFlag")) == false) ? "<img title='未读' src='/images/email_new.gif' border='0'>" : ""%>
						</td>
						<td noWrap align="center"><u title="部门：<%#Eval("DeptName")%>" style="cursor:hand"><%#Eval("UserName")%></u></td>
						<td>
						    <a href="inbox_read_email.aspx?email_id=<%#Eval("EmailId")%>&box_id=<%#Eval("BoxId")%>&page=<%=ViewState["CurrentPage"]%>">
						    <%#Eval("Subject").ToString() == "" ? "[无主题]" : Eval("Subject").ToString()%>
						    <%#(Convert.ToInt32(Eval("Important")) == 1) ? "<span class=\"TextColor1\">重要</span>" : ""%>
						    <%#(Convert.ToInt32(Eval("Important")) == 2) ? "<span class=\"TextColor1\">非常重要</span>" : ""%>
						    </a>
						</td>
						<td noWrap align="center"><%#Eval("SendTime")%></td>
						<td noWrap align="center"><%#formatSize(Convert.ToInt64(Eval("TotalSize")))%></td>
					</tr>
					</AlternatingItemTemplate>
					</asp:Repeater>
					<TR class="TableControl">
						<TD colSpan="6">
							<TABLE class="small" cellSpacing="0" cellPadding="0" width="100%">
								<TR>
									<TD>
									&nbsp;&nbsp;
									<INPUT id="checkAll" onclick="CheckAll(this);" type="checkbox" name="checkAll">
										全部选中&nbsp;&nbsp;
										<asp:Button id="btnDelete" runat="server" EnableViewState="False" Text="删除" CssClass="SmallButton"></asp:Button>&nbsp;&nbsp;
										 转到
										 <SELECT id="sltBoxId" name="sltBoxId" runat="server" class="SmallSelect">				
										 </SELECT>
									</TD>
									<TD align="right">
										<Webdiver:AspNetPager id="AspNetPager1" runat="server" CssClass="small1" AlwaysShow="True" PageSize="10"
											DisabledButtonImageNameExtension="g" CpiButtonImageNameExtension="r" ButtonImageNameExtension="n" 
											ImagePath="../images" PagingButtonSpacing="0" CustomInfoSectionWidth="35%" UrlPaging="True" NumericButtonTextFormatString="[{0}]"
											SubmitButtonText="转到" ShowInputBox="Always" ShowCustomInfoSection="left" HorizontalAlign="Right"
											OnPageChanged="ChangePage" Font-Size="10pt" SubmitButtonClass="SmallButton" InputBoxClass="SmallInput"></Webdiver:AspNetPager>
									</TD>
								</TR>
							</TABLE>
						</TD>
					</TR>
				</TABLE>				
				<table border="0" cellspacing="0" width="95%" class="small" cellpadding="3">
				<tr>
					<td nowrap><img src="/images/delete.gif">
					<a href="javascript:del_read_mail();" title="删除所有已读邮件">删除所有已读邮件</a></td>
				</tr>
				</table>				
				<script>
				function change_box()
				{
					var id_str="";
					var checkList = document.getElementsByTagName("input");
					for(i=0;i<checkList.length;i++)
					{
						if((checkList[i].type == "checkbox") && (checkList[i].id != "checkAll"))
						{
							if(checkList[i].checked)
								id_str += checkList[i].value + ",";
						}
					}
					
					if(id_str=="")
					{
						alert("要转移邮件，请至少选择其中一封。");
						document.Form1.reset();					
						return false;
					}
					
					box_id=document.getElementById("sltBoxId").value;
					url="change_box.aspx?id_str="+ id_str +"&box_id="+box_id+"&old_id=<%=ViewState["BoxId"]%>&page=<%=ViewState["CurrentPage"]%>";
					location=url;			
				}

				function delete_mail()
				{
					var checkNums=0;
					var checkList = document.getElementsByTagName("input");
					for(i=0;i<checkList.length;i++)
					{
						if((checkList[i].type == "checkbox") && (checkList[i].id != "checkAll"))
						{
							if(checkList[i].checked)
								checkNums++;
						}
					}
					
					if(checkNums==0)
					{
						alert("要删除邮件，请至少选择其中一封。");						
						return false;
					}		

					msg='确认要删除所选邮件么？';
					if(window.confirm(msg))
						return true;
					else
						return false;
				}			

				function del_read_mail()
				{
					var msg="确认要删除所有已读邮件？";
					if(window.confirm(msg))
					{
						url="delete_read_email.aspx?box_id=<%=ViewState["BoxId"]%>&page=<%=ViewState["CurrentPage"]%>";
						location=url;
					}			
				}
				</script>
				<br>
			</asp:Panel>
			<asp:Literal id="litMessage" runat="server"></asp:Literal>						
			
		</form>
	</body>
</HTML>
